<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
                    <!-- 引入Vue -->
	<script type="text/javascript" src="../js/vue.js"></script>
    <style>
        .active {
            color: red;
        }
        
        .page {
            list-style: none;
        }
    
        .page>li {
            float: left;
            padding: 5px;
            margin-right: 10px;
            border: 1px solid #ddd;
            background: #eee;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul class="page">
            <li>
                <a @click="prev">上一页</a>
            </li>
            <li v-for="n in pageCount">
                <a :class="activeNumber==n?'active':''">{{n}}</a>
            </li>
            <li>
                <a @click="next">下一页</a>
            </li>
        </ul>
    </div>

    <script>
        var m={
            pageCount:10,
            activeNumber:5
        };

        var vm = new Vue({
            el:'#app',
            data:m,
            methods:{
                prev:function(){
                    if(this.activeNumber>1){
                        this.activeNumber--;
                    }
                },
                next:function(){
                    if(this.activeNumber<10){
                        this.activeNumber++;
                    }
                }
            }
        })
    </script>
</body>
</html>